define(function (require, exports, module) {

	var ue = require('ue-1.4.3');
	var common = require('common');
	require('bootstrap-validator');
	require('bootstrap-datetimepicker');
	require('form-ajax');

	var ued = ue.getEditor('ue-container', {
		initialFrameHeight : 350  //初始化编辑器高度
	});

	$('#datetimepicker').datetimepicker({
		locale : 'zh_cn',
		format : 'YYYY-MM-DD HH:mm:ss'
	});

	var ajaxFrom = $('#pub-form');

	exports.run = function () {
		//表单验证
		ajaxFrom.bootstrapValidator({
			fields : {
				title : {
					validators : {
						notEmpty : {
							message : '请填写资讯标题'
						},
						stringLength : {
							min : 4,
							max : 80
						}
					}
				},
				cid : {
					validators : {
						notEmpty : {
							message : '请选择所属栏目'
						}
					}
				}
			}
		}).on('success.form.bv', function (e) {
			var content = ued.getContent();
			if ( content.length <= 0 ) {
				$.notify('请填写资讯正文', {type : 'danger'});
				$('button[type=submit]').attr('disabled', false);
				return false;
			}
			//表单提交
			common.ajaxForm(ajaxFrom);
		});
	}
});